<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/


empty($do) && $do = 'list';
if ($do == 'edit') {
	$id = getGP('id','G','int');
	$db->query("UPDATE ".DB_TABLEPRE."bbs SET readnum = readnum + 1 WHERE id = '$id'");
	$blog = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."bbs  WHERE id = '$id'");
	include_once('template/views.php');

}elseif ($do == 'save') {
	
	$savetype = getGP('savetype','P');
	$bbsid = getGP('bbsid','P');
	$title = getGP('title','P');
	$author = getGP('author','P');
	$content = getGP('content','P');
	$enddate = get_date('Y-m-d H:i:s',PHP_TIME);
	$uid = $_USER->id;
	//主表信息
	$bbs_log = array(
		'bbsid' => $bbsid,
		'title' => $title,
		'author' => $author,
		'content' => $content,
		'enddate' => $enddate,
		'uid' => $uid
	);
	//写入主表信息
	insert_db('bbs_log',$bbs_log);
	$id=$db->insert_id();
	$bbs = array(
		'enddate' => $enddate
	);
	update_db('bbs',$bbs, array('id' => $bbsid));
	$content=$bbsid.get_inc_log(1).$title.get_inc_log(1).$author.get_inc_log(1).$content.get_inc_log(1).$enddate.get_inc_log(1).$type.get_inc_log(1).$uid;
	$title='回复贴子';
	get_oa_log_dbadd($id,$content,$title,30,$_USER->id);
    goto_page('admin.php?ac=views&fileurl=bbs&do=edit&id='.$bbsid.'');

} elseif ($do == 'delete') {

	$idarr = getGP('id','G');
	$bbsid = getGP('bbsid','G');
	$db->query("DELETE FROM ".DB_TABLEPRE."bbs_log WHERE id = '$idarr'");
	
	goto_page('admin.php?ac=views&fileurl=bbs&do=edit&id='.$bbsid.'');

} 
?>